package com.zcoj.service;

import com.zcoj.core.model.ApiResponse;
import com.zcoj.core.model.PageData;
import com.zcoj.core.model.PageWrap;
import com.zcoj.pojo.Dto.User;
import com.zcoj.pojo.Vo.LoginPageVo;
import com.zcoj.pojo.Vo.RegisterPageVo;
import com.zcoj.pojo.Vo.UserInfoVO;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;
import java.util.Map;

/**
 * Service定义
 * @author 剩xia的盛夏
 * @date 2023/02/24 16:16
 */
@CacheConfig(cacheNames = "UserService")
public interface UserService {

    /**
     * 创建
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @CacheEvict(value = "UserService",allEntries = true)
    Integer create(User user);



    @Cacheable(key = "#p0.toString()+'findByUserName'")
    User findByUserName(String username);
    /**
     * 主键删除
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "UserService",allEntries = true)
    Integer deleteById(Integer id);

    /**
     * 批量主键删除
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "UserService",allEntries = true)
    void deleteByIdInBatch(List<Integer> ids);

    /**
     * 主键更新
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "UserService",allEntries = true)
    Integer updateById(User user);

    @CacheEvict(value = "UserService",allEntries = true)
    Integer saveUserInfo(User user);

    /**
     * 批量主键更新
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "UserService",allEntries = true)
    void updateByIdInBatch(List<User> users);


    @Cacheable(key = "#p0.toString()+'getUserInfoByID'")
    UserInfoVO getUserInfoByID(Integer uid);


    /**
     * 主键查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findById'")
    User findById(Integer id);

    /**
     * 条件查询单条记录
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findOne'")
    User findOne(User user);

    /**
     * 条件查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */


    @Cacheable(key = "#p0.toString()+'findList'")
    List<User> findList(User user);
  
    /**
     * 分页查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findPage'")
    PageData<User> findPage(PageWrap<User> pageWrap);

    /**
     * 条件统计
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    long count(User user);


    @Cacheable(key = "#p0.toString()+'findByEmail'")
    User findByEmail(String email);

    @CacheEvict(value = "UserService",allEntries = true)
    ApiResponse revisePassword(Map<String,String> map);


    @CacheEvict(value = "UserService",allEntries = true)
    ApiResponse reviseEmail(Map<String,String> map);

    ApiResponse checkUserWxBind(Integer uid);

    ApiResponse setWxUserInfo(String ticket,Integer uid);

    ApiResponse verificationCode(LoginPageVo loginPageVo);

    ApiResponse loginByWxTicket(String ticket);

    ApiResponse adminLogin(Map<String,String> map);


    @CacheEvict(value = "UserService",allEntries = true)
    ApiResponse retrievePassword(LoginPageVo loginPageVo);

    ApiResponse registerUser(RegisterPageVo registerPageVo);

    ApiResponse sendEmailCodePost(LoginPageVo loginPageVo);

    Integer sendEmailCode(String email);

    ApiResponse logout();
}
